#!/usr/bin/expect

set timeout 3
spawn su - root
expect "#"
send "ssh-keygen -t rsa"
expect "id_rsa):"
send "\n"
expect "passphrase):"
send "\n"
expect "again:"
send "\n"
expect eof
close


spawn  /usr/bin/ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.0.194

expect {
	"password:"
	{
		send "123123\n"
	}
	"(yes/no)?"
	{
		send "yes\n"
		expect "passdord:"
		send "123123"		
	}
}

expect eof
